﻿using Guwave.MonitorDevice.Common;
using Guwave.MonitorDevice.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Guwave.MonitorDevice.Interface.Entity;

namespace Guwave.MonitorDevice.Service
{
    public class MonitorDevicesService : IMonitorDevicesService
    {
        public MonitorDevicesService()
        {
        }

        /// <summary>
        /// 读取设备全部信息
        /// </summary>
        /// <returns></returns>
        public MonitorDeviceEntity GetDeviceAllInfo()
        {
            //得到ROM的信息
            string[] romInfo = this.GetROMVersion(ROMVersion.DISP);
            //得到SRQ现在的状态
            List<string> srqStatusList= this.GetSRQStatus();
            //得到发生的警报数量及其编号
            AlarmEntity alarmStatusInfo= this.GetAlarmStatus();
            //得到密钥保护状态
            string keyProtectStatus = this.GetKeyProtectStatus();
            //得到温度调节设备连接的感应器型号、温度调节设备的型号、设定温度上限值
            TemperatureEntity temperatureInfo = this.GetTypeInfo();
            //得到设备的槽内状态
            MONEntity monInfo = this.GetMONStatus();
            //得到温度参数
            TempEntity tempParameter = this.GetTempParameter();

            MonitorDeviceEntity monitorDeviceEntity = new MonitorDeviceEntity()
            {
                ROMMode = romInfo[0],
                ROMVersion = romInfo[1],
                SQRStatus = srqStatusList,
                AlarmStatusInfo = alarmStatusInfo,
                KeyProtectStatus = keyProtectStatus,
                TemperatureInfo = temperatureInfo,
                MONInfo = monInfo,
                TempParameter = tempParameter
            };

            return monitorDeviceEntity;
        }

        /// <summary>
        /// 得到该设备温度调整器用ROM的版本
        /// </summary>
        /// <returns></returns>
        public string[] GetROMVersion(ROMVersion rowVersion)
        {
            //"P3PLJCN 1.00.00";
            string[] result = new string[] {
                 "P3PLJCN",
                 " 1.00.00"
            };
            switch (rowVersion)
            {
                    case ROMVersion.Unknown:
                    break;
                    case ROMVersion.DISP:
                    break;
                    case ROMVersion.CONT:
                    break;
            }

            return result;
        }

        /// <summary>
        /// 得到SRQ现在的状态
        /// </summary>
        public List<string> GetSRQStatus()
        {
            List<string> srqStatusList= new List<string>();
            srqStatusList.Add("SRQ1");
            srqStatusList.Add("SRQ2");
            srqStatusList.Add("SRQ3");

            return srqStatusList;
        }

        /// <summary>
        /// 得到发生的警报数量及其编号
        /// </summary>
        public AlarmEntity  GetAlarmStatus()
        {
            AlarmEntity alarmEntity = new AlarmEntity();
            alarmEntity.AlarmCount = "2";
            alarmEntity.AlarmNumber = new List<string>();
            alarmEntity.AlarmNumber.Add("1");
            alarmEntity.AlarmNumber.Add("7");

            return alarmEntity;
        }

        /// <summary>
        /// 得到密钥保护状态
        /// </summary>
        /// <returns></returns>
        public string GetKeyProtectStatus()
        {
            return "ON";
        }

        /// <summary>
        ///  得到温度调节设备连接的感应器型号、温度调节设备的型号、设定温度上限值
        /// </summary>
        /// <returns></returns>
        public TemperatureEntity GetTypeInfo()
        {
            TemperatureEntity temperatureEntity = new TemperatureEntity();
            temperatureEntity.TemperatureSensorModes = new List<string>();
            temperatureEntity.TemperatureSensorModes.Add("干球感应器型号");
            temperatureEntity.TemperatureSensorModes.Add("湿球感应器型号");
            temperatureEntity.TemperatureAdjustMode = "P-300";
            temperatureEntity.TemperatureUpperLimit = "105";

            return temperatureEntity;
        }

        /// <summary>
        /// 得到设备的槽内状态
        /// </summary>
        /// <returns></returns>
        public MONEntity GetMONStatus()
        {
            MONEntity monEntity = new MONEntity();
            monEntity.MeasurementTemperature = "23.0";
            monEntity.MeasurementHumidity = "85";
            monEntity.RunMode = "CONSTANT";
            monEntity.AlarmNumber = "2";

            return monEntity;
        }

         /// <summary>
        /// 得到温度参数
        /// </summary>
        /// <returns></returns>
        public TempEntity GetTempParameter()
        {
            TempEntity tempEntity = new TempEntity();
            tempEntity.MeasurementTemperature = "23.0";
            tempEntity.TemperatureSetting = " 85.0";
            tempEntity.TemperatureUpperLimit = "105.0";
            tempEntity.TemperatureLowerLimit = "-45.0";

            return tempEntity;
        }

        /// <summary>
        /// 返回湿度参数
        /// </summary>
        /// <returns></returns>
        public List<string> GetHUMIInfo()
        {
            List<string> humiInfoList = new List<string>();
            humiInfoList.Add("25");
            humiInfoList.Add("85");
            humiInfoList.Add("100");
            humiInfoList.Add("0");

            return humiInfoList;
        }

        /// <summary>
        /// 返回冷冻机的配置台数和运行状态
        /// </summary>
        /// <returns></returns>
        public List<string> GetREFStatus()
        {
            List<string> refStatusList = new List<string>();
            refStatusList.Add("2");
            refStatusList.Add("ON1");
            refStatusList.Add("OFF2");

            return refStatusList;
        }

        /// <summary>
        /// 返回可控制的加热器点数以及加热器输出值
        /// </summary>
        /// <returns></returns>
        public List<string> GetHotInfo()
        {
            List<string>hotList = new List<string>();
            hotList.Add("2");
            hotList.Add("56.2");
            hotList.Add("19.3");

            return hotList;
        }
    }
}
